An excavator as one working machine includes a running body, an upper swinging body that can swing on the running body, and an one machine on the upper swinging body. The operation machine includes a boom with one end pivotally supported on a base unit, an arm with one end pivotally supported by the other end of the boom, and an attachment pivotally supported by the other end of the arm. The boom, the arm, and the attachment are driven by hydraulic cylinders. For detecting the position and the posture of this operation machine, the stroke of the hydraulic cylinder is measured.
For example, Patent Literature 1 discloses an excavator having a position sensor that detects the position of the piston stroke of the hydraulic cylinder which drives the operation machine with the use of the rotation of a roller rolling on a cylinder rod. Since microscopic slide occurs between this roller and the cylinder rod, a measurement error is generated between the position of the actual stroke and the position of the stroke obtained from the detection result of the position sensor. In view of this, a magnetic sensor as a reset sensor is provided at a reference position on an outer surface of a cylinder tube of the hydraulic cylinder for calibrating the stroke position obtained from the detection result of the position sensor with the reference position. Every time the piston passes the reference position during the operation, the stroke position detected by the position sensor is calibrated, thereby enabling the correct position measurement.